window.onscroll = function() {scrollFunction()};

function scrollFunction() {
    if (document.body.scrollTop > 600 || document.documentElement.scrollTop > 600) {
        document.getElementById("backToTopBtn").style.display = "block";
    } else {
        document.getElementById("backToTopBtn").style.display = "none";
    }
}

document.addEventListener('DOMContentLoaded', function() {
    var backToTopBtn = document.getElementById('backToTopBtn');

    // 检查按钮是否存在
    if (backToTopBtn) {
        backToTopBtn.addEventListener('click', function() {
            // 确保点击事件正确绑定
            window.scrollTo({
                top: 0,
                behavior: 'smooth'
            });
        });
    }
});